<?php session_start(); ?>
<?php include_once 'controller/login.php'; ?>
<?php
if (isset($_GET['name_viewed'])!= NULL) {
    $name_viewed = $_GET['name_viewed'];
}
else if (isset($_SESSION['user_name'])!= NULL) {
    $name_viewed = $_SESSION['user_name'];
}
if (isset($_SESSION['user_name'])!= NULL) {
    $name_logon = $_SESSION['user_name'];
    $temp = new login();
    $role = $temp->getRole($name_logon );
}
else {
    $name_logon = NULL;
    $role = NULL;
}
?>
<?php
include_once ("controller/registrasi.php");
include_once ("controller/login.php");
if(isset ($_GET['logout'])) {
    $logout = new login();
    $logout->logout($_SESSION['user_name']);
}
if(isset ($_GET['block'])) {
    if($_GET['block']) {
        $tempBlockGan = 1;
    }
}
else
    {   $tempBlockGan = 0;}
    if (isset($_GET['name_viewed'])!= NULL) {
    $name_viewed = $_GET['name_viewed'];
}
else if (isset($_SESSION['user_name'])!= NULL) {
    $name_viewed = $_SESSION['user_name'];
}
if (isset($_SESSION['user_name'])!= NULL) {
    $name_logon = $_SESSION['user_name'];
    $temp = new login();
    $role = $temp->getRole($name_logon );
}
else {
    $name_logon = NULL;
    $role = NULL;
}
?>
<?php $judul = "PotoBut Home"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="style1.css"/>
        <script src="home.js" type="text/javascript"></script>
        <title><?php echo $judul; ?></title>
    </head>
    <body class="page">
        <div class="header">
            <a href="index.php">
                <img src="images/logopotobut3.png" alt="potobut_logo" height="129" width="177" border="0"/>
            </a>
        </div>
        <div class="log_in">
            <form action="profil.php" method="post">
                <div class="loginname">
                    <label>User Name </label>
                    <input type="text" name="usernameLogin" id="username"/>
                </div>
                <div class="loginpass">
                    <label>Password  </label>
                    <input type="password" name="passwordLogin" id="password"/>
                </div>
                <div class="loginbutton">
                    <input type="submit" value="Log In" name="submitButtonLogin" id="submitButtonLogin"/>
                </div>
                <?php
                if($tempBlockGan == 1) {
                    echo'<div class="accountblocked">
                    <label>Your PotoBut Account is Blocked</label>
                </div>';
                }
                ?>

            </form>
        </div>
        <div class="isipage">
            <div class="searchgroup">
                <h3>Search</h3>
                <form class="search" action="searchuser.php" method="post">
                    <label class="labelinput">User Name</label>
                    <input class="input" type="text" name="search_user" id="search_user"/>
                    <input class="tombolinput" type="submit" value="Search User" id="search_user_button" name="search_user_button"/>
                </form>
                <form class="search" action="searchphoto.php" method="post">
                    <label class="labelinput">Photo</label>
                    <input class="input" type="text" name="search_photo" id="search_photo"/>
                    <input class="tombolinput" type="submit" value="Search Photo" id="search_photo_button" name="search_photo_button"/>
                </form>
                <div class="space"></div>
                <div class="space"></div>
                

            </div>
            <div class="registrasi">
                <h3>Registration</h3>
                <form class="formLayout" action="login.php" method="post" enctype="multipart/form-data">
                    <div>
                        <label class="labelinput">Nama</label>
                        <input class="input" type="text" name="nama" id="nama" onblur="cekNama(this.value);"/>
                        <div id="cek_nama" class="keterangan"><br/>
                        </div>
                    </div>
                    <div>
                        <label class="labelinput">Username</label>
                        <input class="input" type="text" name="username" id="username" onblur="cekUserName(this.value);"/>
                        <div id="cek_username" class="keterangan"><br/>
                        </div>
                    </div>
                    <div>
                        <label class="labelinput">Password</label>
                        <input class="input" type="password" name="password" id="password" onblur="cekPassword(this.value);"/>
                        <div id="cek_password" class="keterangan"><br/>
                        </div>
                    </div>
                    <div>
                        <label class="labelinput">Re Password</label>
                        <input class="input" type="password" name="rePassword" id="rePassword" onblur="cekRePassword(this.value);"/>
                        <div id="cek_rePassword" class="keterangan"><br/>
                        </div>
                    </div>
                    <div>
                        <label class="labelinput">Tanggal Lahir</label>
                        <input class="input" type="text"  name="tanggalLahir" id="tanggalLahir" onblur="cekTanggal(this.value)"/>
                        <div id="cek_tanggalLahir" class="keterangan"><br/>
                        </div>
                    </div>
                    <div>
                        <label class="labelinput">Email</label>
                        <input class="input" type="text" name="email" id="email" onblur="cekEmail(this.value)"/>
                        <div id="cek_email" class="keterangan"><br/>
                        </div>
                    </div>
                    <div>
                        <label class="labelinput">Foto Profil</label>
                        <input class="input" type="file" name="fotoProfil" id="fotoProfil" onblur="cekFoto(this.value);"/>
                        <div id="cek_foto" class="keterangan"><br/>
                        </div>
                    </div>
                    <div>
                        <label class="labelinput">Jenis kelamin</label>
                        <select class="input" id="jeniskelamin" name="jenisKelamin">
                            <option value="pria">Pria</option>
                            <option value="wanita">Wanita</option>
                        </select>
                        <div>
                            <br/>
                        </div>
                    </div>
                    <div>
                        <label class="labelinput">Lokasi</label>
                        <input class="input" type="text" name="lokasi" id="lokasi" onblur="cekLokasi(this.value);"/>
                        <div id="cek_lokasi" class="keterangan"> <br/>
                        </div>
                    </div>
                    <div>
                        <label  class="labelinput" id="penglihat_label">Wall Privacy</label>
                        <select class="input" id="selectinput" name="wallprivacy">
                            <option value="all_user">All Users</option>
                            <option value="follower_user">Only Follower</option>
                            <option value="owner">Only Owner</option>
                        </select>
                        <div class="space"></div>
                    </div>
                    <div>
                        <input id="reset" type="reset" value="Reset" />
                        <input id="submit" name="submitButton" type="submit" value="Submit" />
                    </div>
                </form>
            </div>
        </div>
        <div class="isipage">
            <div class="panjangrecentphoto">
            <div class="isipagestandar">
                <div>
                    <label id="titlebold">Recent Photos</label>
                </div>
                <div class="space"></div><div class="space"></div>
                <?php
                    include_once 'controller/login.php';
                    include_once 'controller/photo.php';
                    $photo = new photo();
                    $resultPhoto = $photo->showLastUploadedPhoto();
                    $iterate=0;
                    while($row = mysql_fetch_array($resultPhoto)){
                        include_once 'controller/follow.php';
                        $fol = new follow();
                        if ($row['photo_prev'] == 'login_user'){
                            if ($name_logon == NULL){
                                continue;
                            }
                        }else if ($row['photo_prev'] == 'owner'){
                            if ($name_logon != $row['user_name']){
                                continue;
                            }
                        }else if ($row['photo_prev'] == 'follower_user'){
                            $follow = $fol->isFollowing($row['user_name'], $name_logon);
                            if ($name_logon == $row['user_name']){

                            }else if (!$follow){
                                continue;
                            }
                        }
                ?>
                <div class="floatleft" id="photogalleryhome">
                    <?php
                        $urlPict = $row['url_photo'];
                        $urlPhoto = "foto_zoom.php?name_viewed=" . $row['user_name'];
                        $iterate ++;
                        if ($iterate == 11) {
                            break;
                        }
                    ?>
                    <a href="<?php echo $urlPhoto.'&url_foto='.$row['url_photo'] ?>" >
                        <img id="<?php echo "upphoto_" . $iterate?>" name="<?php echo "upphoto_" . $iterate?>" src="<?php echo $urlPict ?>" alt="<?php echo "upphoto_" . $iterate?>" width="80" height="80" border="0"/>
                    </a>

                </div>
                <?php } ?>
            </div>
            </div>
        </div>
        <?php include_once 'Chat/chat.php';?>
        <?php include_once 'Pecahan/footer.php'; ?>
<input type="button" value="Click Here" onClick="tes();">